<template>
	<view>
		<view style="width: 92%;margin:0rpx auto 0;padding-top: 30rpx;">
			<!-- <view style="position: relative;">
				<input type="text"   class="sou" placeholder-class="suo"
					placeholder="请输入地址搜索" confirm-type="search" @confirm="search" />
				<image src="https://static-1310167831.cos.ap-nanjing.myqcloud.com/uploads/20220329/%E5%9B%BE%E5%B1%82%2045%20%E6%8B%B7%E8%B4%9D%202%402x.png"
					class="souicon" mode=""></image>
			</view> -->
			
			<!-- <view style="line-height: 100rpx;font-size: 28rpx;color: #000000;">
				{{city}}
				<text @click="address_xx" style="color: #0078FF;font-size: 24rpx;float: right;margin-left:10rpx ;">获取当前定位</text>
				<image @click="address_xx" src="https://static-1310167831.cos.ap-nanjing.myqcloud.com/uploads/20220329/%E5%9B%BE%E5%B1%82%20600%402x.png" style="width: 30rpx;height: 30rpx;float: right;margin-top: 36rpx;" mode=""></image>
			</view> -->
			<view style="line-height: 60rpx;color: #666666;font-size: 32rpx;">
				请选择地区
			</view>
			<view  @click="jiage"  style="color: #666666;font-size: 26rpx;width: 92%;margin: 10rpx auto;line-height: 80rpx;">
				{{label2 || '选择地区'}}<text class="iconfont icon-xiangyou" style="font-size: 30rpx;float: right;"></text>
			</view>
			
			<view @click="queding" style="width: 100%;height: 90rpx;line-height: 90rpx;text-align: center;background-color: #1fb0ac;color: #FFFFFF;font-size: 26rpx;border-radius: 45rpx;margin: 300rpx auto 0;">
				确定
			</view>
		</view>
		<lb-picker ref="picker6"
		  v-model="value2"
		  mode="multiSelector"
		  :list="list1"
		  :level="2"
		  :dataset="{ name: 'label2' }"
		  @confirm="handleConfirm4">
		</lb-picker>
	</view>
</template>

<script>
	// import QQMapWX from '@/common/qqmap-wx-jssdk.min.js'
	let qqmap;
	import areaData from '@/sub/pages/area-data-min.js'
	import LbPicker from '@/components/lb-picker'
	export default{
		components: {
			LbPicker
		},
		data(){
			return{
				value2: [],
				label2: '',
				list1: areaData,
				province:'',
				city:'',
			}
		},
		onLoad(option) {
			this.province=option.sheng
			this.city=option.shi
			this.label2=option.sheng+'-'+option.shi
			// this.address_xx()
		},
		onReady() {
			qqmap = new QQMapWX({
				// key: ‘PATBZ-EZURU-G***FU-GCBRO-LWFXC’
				key: 'FOPBZ-BUOO4-5RZUS-DHXVW-EBIYJ-PDBSC'
			});
			// this.address_xx()
		},
		methods:{
			jiage:function(){
				this.$refs['picker6'].show()
			},
			handleConfirm4 (e) {
			  // 如果存在多个picker，可以在picker上设置dataset属性，confirm中获取，就能区分是哪个picker了
			  console.log('confirm::', e)
			  if (e) {
			    // const name = e.dataset.name
			    this.label2 = e.item.map(m => m.label).join('-')
			    // if (name && label) {
			    //   this[name] = label
			    // }
			  }
			  this.province=e.item[0].label
			   this.city=e.item[1].label
			},
			
			
			// 获取位置
			address_xx: function() {
				let that = this
				uni.authorize({
					scope: 'scope.userLocation',
					success() { //1.1 允许授权
						that.hqxxdd()
					},
					fail() { //1.2 拒绝授权
						uni.showModal({
							content: '检测到您没打开获取信息功能权限，是否去设置打开？',
							confirmText: "确认",
							cancelText: '取消',
							success: (res) => {
								if (res.confirm) {
									uni.openSetting({
										success: (res) => {
											console.log(res);
											that.hqxxdd()
										}
									})
								} else {
									console.log('取消');
									return false;
								}
							}
						})
						return false;
					}
				})
			},
			// 获取详细地址
			// hqxxdd: function(e) {
			// 	let that = this
				
			// 		type: 'wgs84',
			// 		success: function(res) {
			// 			console.log(res)
			// 			that.longitude = res.longitude
			// 			that.latitude = res.latitude
			// 			console.log('当前位置的经度：' + res.longitude);
			// 			console.log('当前位置的纬度：' + res.latitude);
			// 			uni.setStorageSync('longitude', res.longitude)
			// 			uni.setStorageSync('latitude', res.latitude)
			// 			qqmap.reverseGeocoder({
			// 				location: {
			// 					latitude: res.latitude,
			// 					longitude: res.longitude
			// 				},
			// 				success: function(re) {
			// 					console.log(re,111111111)
			// 					that.province = re.result.address_component.province
			// 					that.city = re.result.address_component.city
			// 					that.area = re.result.address_component.district
			// 					uni.setStorageSync('address', re.result.address)
								
			// 				},
			// 				fail: function(res) {
			// 					uni.showToast({
			// 						title: '定位失败',
			// 						duration: 2000,
			// 						icon: "none"
			// 					})
			// 					console.log(res);
			// 				},
			// 				complete: function(res) {
			
			// 				}
			// 			})
			// 		}
			
			// 	});
			// },
			queding:function(){
				let pages = getCurrentPages();
				let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
				//修改上一页data里面的searchVal参数值为1211
				prevPage.$vm.xuan_sheng=this.province
				prevPage.$vm.xuan_shi=this.city
				uni.setStorageSync('xuan_sc_type',1)
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #ffffff!important;
		font-family: Demibold;
	}
	.sou {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		border-radius: 40rpx;
		color: #000000;
		font-size: 26rpx;
		box-sizing: border-box;
		padding: 0 30rpx 0 80rpx;
		background-color: #F6F6F6;
	}
	.suo {
		color: #767676;
		opacity: 1;
		font-size: 26rpx;
	}
	
	.souicon {
		width: 30rpx;
		height: 30rpx;
		position: absolute;
		top: 50%;
		left: 30rpx;
		transform: translateY(-50%);
	
	}
</style>
